#include "NewtonInterpolation.hpp"

using namespace std;


int main() {
    vector<double> day = {0, 6, 10, 13, 17, 20, 28};
    vector<double> sp1 = {6.67, 17.3, 42.7, 37.3, 30.1, 29.3, 28.7};
    vector<double> sp2 = {6.67, 16.1, 18.9, 15.0, 10.6, 9.44, 8.89};

    NewtonInterpolation f1(day, sp1);
    NewtonInterpolation f2(day, sp2);
    double min1=f1(28),min2=f2(28);
    
    for (double i=28; i<=43; i+=0.01){
        if(f1(i)<=min1){
            min1=f1(i);
        }
        if(f2(i)<=min2){
            min2=f2(i);
        }
    }

    cout << "Predicted min weight of Sp1 at day 43: " << min1 << endl;
    cout << "Predicted min weight of Sp2 at day 43: " << min2 << endl;

    if (min1 <= 0) {
        cout << "Sp1 is predicted to die after 15 more days." << endl;
    } else {
        cout << "Sp1 is predicted to survive after 15 more days." << endl;
    }

    if (min2 <= 0) {
        cout << "Sp2 is predicted to die after 15 more days." << endl;
    } else {
        cout << "Sp2 is predicted to survive after 15 more days." << endl;
    }

    return 0;
}